import apis from '@/apis'
import store from '@/store'
import {
	toast
} from '@/utils/lib'
import {
	downFileUrl
} from '@/config/url'
class Lib {
	// 增加代理函数名错误检测
	constructor() {
		// #ifdef MP-WEIXIN
		this.fs = uni.getFileSystemManager() //文件系统
		// #endif

		return new Proxy(this, {
			get(target, key) {
				if (key in target) {
					return target[key]
				} else {
					toast('核心函数名不存在')
				}
			}
		})
	}
	
	//选择图片
	chooseImage(){
		return new Promise(resolve=>{
			uni.chooseImage({
				count: 1,
				success: res => {
					resolve(res.tempFilePaths[0])
				}
			})
		})
	}
	
	//选择视频
	chooseVideo(){
		return new Promise(resolve=>{
			uni.chooseVideo({
				count: 1,
				sourceType: ['camera', 'album'],
				success: res => {
					resolve(res)
				}
			});
		})
	}
	
	//微信支付
	pay({timeStamp,nonceStr,Package,signType,paySign}){
		return new Promise((resolve,reject)=>{
			uni.requestPayment({
				provider: 'wxpay',
				timeStamp,
				nonceStr,
				package:Package,
				signType,
				paySign,
				success:res=> {
					resolve(JSON.stringify(res))
				},
				fail:err=>{
					reject(JSON.stringify(err))
				}
			});
		})
	}

}
export default new Lib()
